<?php
include('../../inc/global.inc');
include("../islogin.php");
$url=$_SERVER['HTTP_REFERER'];
?>
<?php
if($_POST[act_tj]){
mysql_query("insert into template (t_id,t_type,t_name,picture) values ('$_POST[t_id]','$_POST[t_type]','$_POST[t_name]','$_POST[picture]')");
echo "<script>location='".$_POST[url]."';</script>";
}
?>
<?php
if($_POST['act_xg']){
mysql_query("update template set t_id='$_POST[t_id]',t_type='$_POST[t_type]',t_name='$_POST[t_name]',picture='$_POST[picture]' where id='".$_POST['iid']."'");

echo "<script>location='".$_POST[url]."';</script>";
}
?>
<HTML>
<HEAD>
<TITLE>Admin</TITLE>
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<LINK href="../css/css.css" rel=stylesheet>
<script type='text/javascript' src="../js/islogin.js" charset="gb2312"></script>
</HEAD>
<BODY>
<center>
  <table width="600" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
    <tr>
      <td height="25" bgcolor="#EEEEF9" style="padding-left:5px;">添加、修改模板&nbsp;&nbsp;<a href="javascript:history.go(-1)">返回</a></td>
    </tr>
  </table>
<?php
if($_GET[tj]){
?>
  <table width="600" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
  <form method="post" action="" name="form1">
    <tr>
      <td height="30" colspan="2" align="center" bgcolor="#8DA8CF">添加模板</td>
    </tr>
    <tr>
      <td width="26%" height="30" align="center" bgcolor="#FFFFFF">模板名称</td>
      <td width="74%" align="left" bgcolor="#FFFFFF" style="padding-left:2px;"><input name="t_name" type="text" id="t_name" size="30" maxlength="50"></td>
    </tr>
	<tr>
      <td width="26%" height="30" align="center" bgcolor="#FFFFFF">模板编号</td>
      <td width="74%" align="left" bgcolor="#FFFFFF" style="padding-left:2px;"><input name="t_id" type="text" id="t_id" size="10" maxlength="20"></td>
    </tr>
	<tr>
      <td width="26%" height="30" align="center" bgcolor="#FFFFFF">模板等级</td>
      <td width="74%" align="left" bgcolor="#FFFFFF" style="padding-left:2px;"><select name="t_type">
	  <option value="3">普通会员</option>
	  <option value="6">钻石会员</option>
	  </select></td>
    </tr>
<TR>
    <TD align="center" bgColor="#FFFFFF" height="25">图片</TD>
    <TD bgColor="#f9f9f9" style="padding-left:2px;"><INPUT name="picture" value="" size="35">
&nbsp;
<input name="button" type="button" onClick="window.open ('../admin_upfile.php', 'newwindow', 'height=50, width=400, top=250, left=250, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no')" value="上传图片"></TD>
  </TR>
    <tr><input type="hidden" name="url" value="<?=$url?>">
	<input type="hidden" name="act_tj" value="ok">
      <td height="30" colspan="2" align="center" bgcolor="#FFFFFF"><input type="submit" value="提交"></td>
    </tr>
	</form>
  </table>
<?php
}
?>
  <?php
if($_GET['xg']){
$sql="select * from template where id=".$_GET['xg_id'];
$rs=mysql_query($sql);
$row=mysql_fetch_array($rs)
?>
<table width="600" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
    <form method="post" action="" onSubmit="return check()" name="form1">
      <tr>
        <td height="30" colspan="2" align="center" bgcolor="#8DA8CF">修改模板</td>
      </tr>
    <tr>
      <td width="26%" height="30" align="center" bgcolor="#FFFFFF">模板名称</td>
      <td width="74%" align="left" bgcolor="#FFFFFF" style="padding-left:2px;"><input name="t_name" type="text" id="t_name" size="30" maxlength="50" value="<?=$row[t_name]?>"></td>
    </tr>
	<tr>
      <td width="26%" height="30" align="center" bgcolor="#FFFFFF">模板编号</td>
      <td width="74%" align="left" bgcolor="#FFFFFF" style="padding-left:2px;"><input name="t_id" type="text" id="t_id" size="10" maxlength="20" value="<?=$row[t_id]?>"></td>
    </tr>
	<tr>
      <td width="26%" height="30" align="center" bgcolor="#FFFFFF">模板等级</td>
      <td width="74%" align="left" bgcolor="#FFFFFF" style="padding-left:2px;"><select name="t_type">
	   <option value="3" <?php if($row[t_type]=='3'){echo "selected";}?>>普通会员</option>
	   <option value="6" <?php if($row[t_type]=='6'){echo "selected";}?>>钻石会员</option>
	  </select></td>
    </tr>
<TR>
    <TD align="center" bgColor="#FFFFFF" height="25">图片</TD>
    <TD bgColor="#f9f9f9" style="padding-left:2px;"><?php if($row[picture]){?><img src="http://www.sandib2b.cn/img/<?=$row[picture]?>" width="140" height="104" border="0"><br><?php }?><INPUT name="picture" value="<?=$row[picture]?>" size="35">
&nbsp;
<input name="button" type="button" onClick="window.open ('../admin_upfile.php', 'newwindow', 'height=50, width=400, top=250, left=250, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no')" value="上传图片"></TD>
  </TR>
      <tr><input type="hidden" name="url" value="<?=$url?>">
        <input type="hidden" name="act_xg" value="ok"><input type="hidden" name="iid" value="<?=$row['id']?>">
        <td height="30" colspan="2" align="center" bgcolor="#FFFFFF"><input name="submit" type="submit" value="提交"></td>
      </tr>
    </form>
  </table>
  <?php
}?>
</center>
</BODY>
</HTML>
